<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>新增病房</title>
    <link href="/plugins/layui/css/layui.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form class="layui-form" action="/ward?action=save" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">病房号</label>
        <div class="layui-input-inline">
            <input type="hidden" name="id" value="${dept.id }"/>
            <input type="text" id="wardno" name="wardno" lay-verify="title"
                value="${ward.wardno }" autocomplete="off" placeholder="请输入病房号"
                class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" id="address" value="${ward.address}" autocomplete="off"
                       placeholder="请输入地址" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">科室</label>
            <div class="layui-input-inline">
                <select id="deptId" name="deptId">

                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <input type="button" onclick="history.go(-1)" class="layui-btn" value="返回">
        </div>
    </div>
</form>
<script src="/plugins/layui/layui.js"></script>
<script type="text/javascript">
    layui.use('form', function () {
        var form = layui.form;
        var $ = layui.jquery;

        var deptId = "${ward.deptId}";

        $.get("/dept?action=all", function (ret) {
            var options = "";
            $.each(ret, function (i, v) {
                options = options + "<option value='" + v.id + "'";
                if(v.id == deptId){
                    options = options + " selected ";
                }
                options = options + ">" + v.name + "</option>";
            });
            $("#deptId").html(options);
            form.render("select");
        });
    });

</script>
</body>
</html>